class Music {
  constructor() {
    this._music = document.createElement('audio');
    this._music.loop = true
  }
  init() {
    const self = this;
    const _handle = () => {
      this._music.play()
      document.body.removeEventListener('touchstart', _handle)
    }
    document.body.addEventListener('touchstart', _handle)
    window.wx && window.wx.ready(function() {
      self._music.play()
    })
  }
  addEventListener(event, fn) {
    this._music.addEventListener(event, fn)
  }
  pause() {
    this._music.pause()
  }
  play() {
    this._music.play()
  }
  setMusic(musicSrc) {
    this._music.src = musicSrc
  }
}

export default new Music()
